//
//  YLListItemExampleController.m
//  YLScaner
//
//  Created by Admin on 2025/9/26.
//

#import "YLListItemExampleController.h"
#import <LanYouToolBox/YLCommonListItemCell.h>



@interface YLListItemExampleController ()

@end

@implementation YLListItemExampleController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.title = @"列表项";
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
    
    self.tableView.estimatedRowHeight = 200;
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    
    
    [YLCommonListItemCell registerWithTableView:self.tableView];
//    [self.tableView registerNib:[UINib nibWithNibName:@"YLCommonListItemCell" bundle:nil] forCellReuseIdentifier:@"cell"];
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        
    YLCommonListItemCell *cell = [YLCommonListItemCell cellWithTableView:tableView indexPath:indexPath];
    
    // 默认设置
    cell.assistImage.image = [UIImage systemImageNamed:@"chevron.right"];
    cell.assistImage.tintColor = [UIColor colorWithRed:47/255.0 green:47/255.0 blue:47/255.0 alpha:1];
    cell.iconImage.tintColor = UIColor.whiteColor;
    cell.iconRadius = 4;
    
    // 飞行模式
    if (indexPath.row == 0 && indexPath.section == 0){
        
        cell.iconImage.image = [UIImage systemImageNamed:@"airplane"];
        cell.iconImage.backgroundColor = UIColor.orangeColor;
    
        
        cell.mainTitle.text = @"飞行模式";
        cell.assistSwitch.hidden = NO;
        cell.assistImage.hidden = YES;
        cell.assistSwitch.on = NO;
    }
    
    // 无线局域网
    if (indexPath.row == 1 && indexPath.section == 0){
        
        cell.iconImage.image = [UIImage systemImageNamed:@"wifi"];
        cell.iconImage.backgroundColor = UIColor.blueColor;
        
        cell.mainTitle.text = @"无线局域网";
        cell.assistLabel.text = @"未连接";
    }
    
    // 蓝牙
    if (indexPath.row == 2 && indexPath.section == 0){
        
        cell.iconImage.image = [UIImage systemImageNamed:@"wifi"];
        cell.iconImage.backgroundColor = UIColor.blueColor;
        
        cell.mainTitle.text = @"无线局域网";
        cell.assistLabel.text = @"未连接";
    }
    
    // 蜂窝网络
    if (indexPath.row == 3 && indexPath.section == 0){
        
        cell.iconImage.image = [UIImage systemImageNamed:@"network"];
        cell.iconImage.backgroundColor = UIColor.greenColor;
        
        cell.mainTitle.text = @"蜂窝网络";
    }

    
    // 个人热点
    if (indexPath.row == 4 && indexPath.section == 0){
        
        cell.iconImage.image = [UIImage systemImageNamed:@"personalhotspot"];
        cell.iconImage.backgroundColor = UIColor.greenColor;
        
        cell.mainTitle.text = @"个人热点";
        cell.assistLabel.text = @"关闭";
    }


    
    
    // 通用
    if (indexPath.row == 0 && indexPath.section == 1){
        
        cell.iconImage.image = [UIImage systemImageNamed:@"gear"];
        cell.iconImage.backgroundColor = UIColor.grayColor;
    
        
        cell.mainTitle.text = @"通用";
    }
    
    // 控制中心
    if (indexPath.row == 1 && indexPath.section == 1){
        
        cell.iconImage.image = [UIImage systemImageNamed:@"switch.2"];
        cell.iconImage.backgroundColor = UIColor.grayColor;
        
        cell.mainTitle.text = @"控制中心";
    }
    
    if (indexPath.row == 2 && indexPath.section == 1){
    
        cell.mainTitle.text = @"当前版本";
        cell.assistLabel.text = @"v 1.2.4";
    }
    
    if (indexPath.row > 2 && indexPath.section == 1){
    
        cell.mainTitle.text = @"主标题";
        cell.subTitle.text = @"副标题";
    }
    
    
    //
    if (indexPath.row == 0)
    {
        cell.radius = 8;
        cell.corner = UIRectCornerTopLeft | UIRectCornerTopRight;
    }else if (indexPath.row == 4)
    {
        cell.radius = 8;
        cell.bottomLine.hidden = YES;
        cell.corner = UIRectCornerBottomLeft | UIRectCornerBottomRight;
    }else{
        
        cell.radius = 0;
    }
    
    
//    cell.iconImage.image =  [UIImage imageNamed:@"铃铛"];

    
    
    
    return cell;
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/




@end
